package com.czh.www.util;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;

/**
 * @author idcomcn
 */
public class CzhResources {

    /**
     * idcomcn
     *
     * @param filename
     * @return
     */
    public static Image getImage(String filename) {
        BufferedImage bi = null;
        InputStream in = CzhResources.class.getResourceAsStream(filename);
        try {
            bi = ImageIO.read(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return bi;
    }

    /**
     * idcomcn
     *
     * @param filename
     * @return
     */
    public static ImageIcon getImageIcon(String filename) {
        ImageIcon imageIcon = null;
        InputStream in = CzhResources.class.getResourceAsStream(filename);
        try {
            BufferedImage bi = ImageIO.read(in);
            imageIcon = new ImageIcon(bi);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return imageIcon;
    }
}